import * as THREE from 'three';
const OPType = {
  EXECUTE: 'execute',
  VERIFY: 'verify',
  VIEW: 'view'
}
const ColorModeEnum = {
  HEIGHT: 0.0,
  PURE: 1.0,
  RGB: 2.0,
  VELOCITY: 3.0,
}
const withoutTaskId = '-1';
const StatusType = {
  Default: '',
  Create: 'Create',
  Pick: 'Pick',
  Loading: 'Loading',
  Modal: 'Modal',
  Confirm: 'Confirm',
  // play
  Play: 'Play',
}
const toMap = (arr) => {
  let map = {};
  arr.forEach((e) => (map[e] = true));
  return map;
}
const empty = {
  name: 'empty',
  op: OPType.VIEW,
  ui: toMap([]),
  actions: toMap([]),
}
const getDefaultConfig = () => {
  return {
    imgViewPrefix: 'image-2d-small',
    singleViewPrefix: 'image-2d-max',
    //
    // showClassView: false,
    showImgView: true,
    showSingleImgView: false,
    showSideView: true,
    showOperationView: true,
    // showCheckView: false,
    // showCheckClassView: false,
    // showCheckViewImgMax: false,
    showLabel: false,
    // showAnnotation: true,
    showAttr: false,
    enableShowAttr: false,
    //
    // filter2DByTrack: false,
    singleImgViewIndex: 0,
    imgRegionIndex: -1,
    //
    // activeRect: false,
    // active2DBox: false,
    // active3DBox: false,
    // activeAnnotation: false,
    activeTranslate: false,
    // activeCreateComment: false,
    // activeTrack: false,
    circleRadius: 100,
    activeHelper2d: ['aux_line'],
    // project
    projectPoint4: true,
    projectPoint8: true,
    projectMap3d: true,
    // config
    pointSize: 0.1,
    heightRange: [-10000, 10000],
    groundEnable: true,
    // render
    edgeColor: ['#000dff', '#ff0000'],
    singleColor: '#87abff',
    pointColorMode: ColorModeEnum.HEIGHT,
    pointIntensity: [0, 255],
    openIntensity: false,
    brightness: 1,
    pointGround: -1.5,
    pointColors: ['#141ff0', '#Fab942'],
    pointHeight: [-Infinity, Infinity],
    pointVelocity: [-Infinity, Infinity],
    pointInfo: {
        count: 0,
        hasIntensity: false,
        hasVelocity: false,
        hasRGB: false,
        intensityRange: new THREE.Vector2(),
        vRange: new THREE.Vector2(),
        min: new THREE.Vector3(),
        max: new THREE.Vector3(),
        vCount: 0,
    },
    renderRect: true,
    // renderProjectRect: true,
    renderBox: true,
    renderProjectBox: true,
    renderProjectPoint: false,
    //
    FILTER_ALL: 'All',
    aspectRatio: 1.78,
    maxViewHeight: '100%',
    maxViewWidth: '100%',
    limitRect2Image: true,
    withoutTaskId: withoutTaskId,
    boxMethod: 'AI',
    autoLoad: false,
    polyline3D: true,
  };
}
export const getDefaultState = () => {
  return {
    // lang: 'zh',
    // pointUrl: '',
    // user: {
    //     id: 'test-123123',
    // },
    // filters: [],
    // filterActive: [],
    frames: [],
    frameIndex: -1,

    // classifications: [],
    isSeriesFrame: false,
    currentClass: '',
    // models: [],
    // modelConfig: {
    //     confidence: [0.5, 1],
    //     predict: true,
    //     classes: {},
    //     model: '',
    //     loading: false,
    //     start: 0,
    //     duration: 0,
    // },
    // annotations: [],
    recentClass: [],

    config: getDefaultConfig(),
    imgViews: [],
    // mode: 'empty',
    // modeConfig: Modes.empty,
    // modelConfig: empty,
    status: StatusType.Default,
    // classTypes: [],
    activeSourceData: withoutTaskId,
    sources: [],
    sourceFilters: [],
  }
}